package com.hu.service.Impl;

import com.hu.mapper.UniversityMapper;
import com.hu.pojo.University;
import com.hu.service.UniversityService;
import com.hu.vo.UniversityVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author ZhouKai
 * 2022/4/20 16:05
 */
@Service
public class UniversityServiceImpl implements UniversityService {
    @Autowired
    UniversityMapper universityMapper;

    /**
     * 获取院校信息
     *
     * @param id 院校代码
     * @return 院校信息
     */
    @Override
    public UniversityVo getUniversity(Integer id) {
        University universityById = universityMapper.getUniversityById(id);
        if (universityById == null) {
            return null;
        }
        return new UniversityVo(universityById);
    }

    /**
     * 获取院校信息
     *
     * @param schoolName 院校名称
     * @return 院校信息
     */
    @Override
    public UniversityVo getUniversity(String schoolName) {
        Integer id = universityMapper.getIdBySchoolName(schoolName);
        return getUniversity(id);
    }
}
